SUBSYSTEM!="net", GOTO="netrename_end"

IMPORT{builtin}="path_id"

ACTION=="move", IMPORT{db}="ID_NET_DRIVER"

ACTION!="add", GOTO="netrename_end"

IMPORT{builtin}="net_setup_link"
# test this ^ with: udevadm test-builtin net_setup_link /sys/class/net/net0
# it only shows ID_NET_DRIVER=r8169 whereas this:
# udevadm info -p $(udevadm info -q path `realpath /sys/class/net/net0`)
# ^ shows lots more, like: ID_MODEL_ID=0x8136 which we can't seem to be able to match on!

#rename enp1s0 (actually eth0 since this runs before 80-net-setup-link.rules) to net0
ENV{ID_NET_DRIVER}=="r8169", NAME="net0"
#the following won't match[unless I typoed something when testing] (and can't find built-in which provides them):
#ENV{ID_MODEL_ID}==0x8136, NAME="net0"
#ENV{ID_MODEL_ID}=="0x8136", NAME="net0"

LABEL="netrename_end"
# ^ no idea if these labels should be unique globally or just unique within each .rules file

#none of the following work (alone, without the above^):
#SUBSYSTEM=="net", ACTION=="add", ID_MODEL_ID=="0x8136", NAME="net0"
#SUBSYSTEM=="net", ACTION=="add", ENV{ID_MODEL_ID}==0x8136, NAME="net0"
# SUBSYSTEM=="net", ACTION=="add", ID_MODEL_ID==0x8136, NAME="net0"
# SUBSYSTEM=="net", ACTION=="add", ENV{ID_MODEL_ID}=="0x8136", NAME="net0"
# SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_DRIVER}=="r8169", NAME="net0"

# "Note: When choosing the static names it should be avoided to use names in the format of "ethX" and "wlanX", because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g.: net0, net1, wifi0, wifi1"
# from: https://wiki.archlinux.org/index.php/Network_configuration#Change_device_name


